class Solution:
def getMax(self, red, n, blue, m):
mx1 = 0
local = 0
for x in red:
local += x
mx1 = max(mx1, local)
mx2 = 0
local = 0
for x in blue:
local += x
mx2 = max(mx2, local)
print(mx1 + mx2)
return
def main():
t = int(input())
sol = Solution()
while t:
n = int(input())
red = list(map(int, input().strip().split()))
m = int(input())
blue = list(map(int, input().strip().split()))
sol.getMax(red, n, blue, m)
t -= 1
if __name__ == '__main__':
main()
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int INF=0x3f3f3f3f;
inline int read()
{
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0',c=getchar();}
return x*f;
}
const int N=110;
int a[N],b[N];
void solve()
{
int n=read();
for(int i=1;i<=n;i++)a[i]=read();
int m=read();
for(int i=1;i<=m;i++)b[i]=read();
int ans1=0,ans2=0,sum1=0,sum2=0;
for(int i=1;i<=n;i++)sum1+=a[i],ans1=max(ans1,sum1);
for(int i=1;i<=m;i++)sum2+=b[i],ans2=max(ans2,sum2);
cout<<ans1+ans2<<endl;
}
int main()
{
int T=read();
while(T--)solve();
return 0;
}
1630A - And Matching | 1630B - Range and Partition |
1630C - Paint the Middle | 1630D - Flipping Range |
1328A - Divisibility Problem | 339A - Helpful Maths |
4A - Watermelon | 476A - Dreamoon and Stairs |
1409A - Yet Another Two Integers Problem | 977A - Wrong Subtraction |
263A - Beautiful Matrix | 180C - Letter |
151A - Soft Drinking | 1352A - Sum of Round Numbers |
281A - Word Capitalization | 1646A - Square Counting |
266A - Stones on the Table | 61A - Ultra-Fast Mathematician |
148A - Insomnia cure | 1650A - Deletions of Two Adjacent Letters |
1512A - Spy Detected | 282A - Bit++ |
69A - Young Physicist | 1651A - Playoff |
734A - Anton and Danik | 1300B - Assigning to Classes |
1647A - Madoka and Math Dad | 710A - King Moves |
1131A - Sea Battle | 118A - String Task |